#ifndef SPLIT_TOOL_H
#define SPLIT_TOOL_H

#include "cppjieba/Jieba.hpp"

#include <vector>
#include <string>
#include <fstream>
#include <sstream>

using std::vector;
using std::string;
using std::ifstream;
using std::stringstream;
using std::istringstream;

//调用jieba库进行分词
//同时也能进行英文分词
class SplitTool
{
public:
    static SplitTool* getInstance()
    {
        if(_pInstance == nullptr)
        {
            _pInstance = new SplitTool();
        }
        return _pInstance;
    }
    static void destory()
    {
        if(_pInstance)
        {
            delete _pInstance;
            _pInstance = nullptr;
        }
    }
    //切割方法
    void cutChineseWord(string filePath, vector<string> &words);
    void cutEnglishWord(string filePath, vector<string> &words);
    //切割方法的重载形式,为了处理字符串而非文件
    void cutChineseWord(string str, vector<string> &words, int placeholder);
    void cutEnglishWord(string str, vector<string> &words, int placeholder);

private:
    SplitTool();
    ~SplitTool();

    //删除拷贝构造和赋值运算符函数
    SplitTool(SplitTool & rhs) = delete;
    SplitTool & operator=(SplitTool & rhs) = delete;
private:
    const char* const DICT_PATH = "./dict/jieba.dict.utf8";
    const char* const HMM_PATH = "./dict/hmm_model.utf8";
    const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
    const char* const IDF_PATH = "./dict/idf.utf8";
    const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";

    static SplitTool *_pInstance;
    cppjieba::Jieba _jieba;

};



#endif //SPLIT_TOOL_H